Skip to content

gh-111089: Add cache to PyUnicode_AsUTF8() for embedded NUL#111587

Closed
vstinner wants to merge 9 commits intopython:mainfrom
vstinner:unicode_embed_null
Closed

gh-111089: Add cache to PyUnicode_AsUTF8() for embedded NUL#111587
vstinner wants to merge 9 commits intopython:mainfrom
vstinner:unicode_embed_null

Conversation

@vstinner
Copy link
Member

@vstinner vstinner commented Nov 1, 2023

Add PyASCIIObject.state.embed_null member to Python str objects. It is used as a cache by PyUnicode_AsUTF8() to only check once if a string contains a null character. Strings created by PyUnicode_FromString() initializes embed_null since the string cannot contain a null character.

Global static strings now also initialize the embed_null member. The chr(0) singleton ("\0" string) is the only static string which contains a null character.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants